//--------------------------------------------------------------------------------
// Alec G Thilenius
//
// This software is distributed under the MIT License, available at the following
// URL:
// http://www.opensource.org/licenses/mit-license.php
//--------------------------------------------------------------------------------

#pragma once

#include "PCH.h"

using namespace std;

extern int indAmt;
extern bool didFail;
extern bool suiteFail;
extern string currentTestname;

#define SUITE_BEGIN(SuiteName) \
	cout << Indent << color_blue << "Suite: " << SuiteName << color_white << endl; \
	indAmt++; \
	indAmt++; \
	suiteFail = false; \

#define SUITE_END\
	indAmt--; \
	indAmt--; \
	cout << color_blue << "|" << color_white << endl; \
	if ( suiteFail ) \
	cout << Indent << color_red << "Failed!" << color_white << endl; \
	else \
	cout << Indent << color_green << "Passed." << color_white << endl; \
	cout << endl; \
	suiteFail = false; \

#define TEST_BEGIN(TestName) do \
{\
	cout << color_blue << "|" << color_white << endl; \
	indAmt--;\
	cout << Indent << color_blue << "Test: " << TestName << color_white << endl; \
	indAmt++; \
	didFail = false; \
	currentTestname = TestName; \
} while (0);\

#define TEST_END do \
{ \
	indAmt--; \
	if ( didFail ) \
	cout << Indent << color_red << "Failed!" << color_white << endl; \
	else \
	cout << Indent << color_green << "Passed." << color_white << endl; \
	indAmt++; \
} while (0); \

inline void IsTrue ( string testName, bool result, string message )
{
	if ( result )
	{
		cout << Indent << color_green << "- " << testName << color_white << endl;
	}
	else
	{
		cout << Indent << color_red << "- " << testName << color_white << ": " << endl;
		indAmt ++;
		cout << Indent << color_yellow << message << color_white << endl;
		indAmt --;
		didFail = true;
		suiteFail = true;
	}
}

inline void IsFalse ( string testName, bool result, string message )
{
	IsTrue ( testName, !result, message );
}

inline void Error ( string testName, string message )
{
	didFail = true;
	suiteFail = true;
	cout << Indent << color_red << testName << ": Fatal error: " << message << color_white << endl;
}